import React from "react";
import { useRoutes} from "react-router-dom";
import {Navigate} from "react-router-dom";
import { RouteObject } from "../types";
import LazyLoad from "./utils/LazyLoad";
import Layout from '../views/layout';

export const router_items:Array<RouteObject>= [
{
    path: "/",
    element: <Navigate to="/layout/home"/>,
    meta:{
      key:"/",
      unWantedAuth: false
    }
},
{
  path:"/login",
  element: LazyLoad(React.lazy(()=>import('../views/login'))),
  meta: {
    unWantedAuth: true,
    key:"/login"
  }
},
{
  path: "/layout",
  element: <Layout/>,
  meta: {
    unWantedAuth: false,
    key:"/layout"
  },
  children: [
    {
      path:"home",
      element: LazyLoad(React.lazy(()=>import('../views/home'))),
      meta:{
        unWantedAuth: false,
        key: "/layout/home"
      }
    },
    {
      path: "home2",
      element: LazyLoad(React.lazy(()=>import('../views/home2'))),
      meta:{
        key:"/layout/home2",
        unWantedAuth: false
      }
    },
    { 
      path: "user", 
      element: LazyLoad(React.lazy(()=>import('../views/user'))),
      meta: {
        key:"/layout/user",
        unWantedAuth: false
      }
    },
  ],
}
]
function GetRouters() {
  const routes=useRoutes(router_items);

  return routes;
}
export default GetRouters;